package edu.neusoft.springhtmldemo.mapper;

import edu.neusoft.springhtmldemo.domain.CameraManagement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CameraManagementMapper {
    @Select("select * from cameramanagemententity")
    List<CameraManagement> selectAll();

    @Select("update cameramanagemententity \n" +
            "set cameraIP=#{cameraIP},\n" +
            "userName=#{userName} ,\n" +
            "pswd=#{pswd} ,\n" +
            "RTSPaddress=#{RTSPaddress} \n" +
            "where cameraID=#{cameraID}")
    void updateCameraManagement(CameraManagement cameraManagement);

    @Select("INSERT into cameramanagemententity(cameraIP,userName,pswd,RTSPaddress)\n" +
            "value(#{cameraIP},#{userName},#{pswd},#{RTSPaddress})")
    void addCameraManagement(CameraManagement cameraManagement);

    @Select("delete from cameramanagemententity where cameraID in (#{cameraID})")
    void delCameraManagement(Integer cameraID);

    @Select("select * from cameramanagemententity\n" +
            "where cameraID like '%' #{cameraID} '%'\n" +
            "and cameraIP like '%' #{cameraIP} '%'\n" +
            "and userName like '%' #{userName} '%'\n" +
            "and pswd like '%' #{pswd} '%'\n" +
            "and RTSPaddress like '%' #{RTSPaddress} '%'")
    List<CameraManagement> selectCameraManagement(String cameraID, String cameraIP, String userName, String pswd, String RTSPaddress);

    @Select("SELECT cameraIP from cameramanagemententity")
    List<String> cameraIPValues();
}
